package cn.djun.news.util;

import lombok.Data;
import org.springframework.http.ResponseEntity;

/**
 * @author djun
 * @classname BaseResponse
 * @description
 * @date 2020/11/23 10:04
 * @email 3170495286@qq.com
 */
@Data
public class BaseResponse<T> {
    /**
     * 响应码
     */
    private int responseCode;
    /**
     * 响应消息
     */
    private String responseMsg;
    /**
     * 响应数据
     */
    private T data;

    public BaseResponse(int responseCode, String responseMsg, T data) {
        this.responseCode = responseCode;
        this.responseMsg = responseMsg;
        this.data = data;
    }

    /**
     * 请求方法
     *
     * @param code
     * @param message
     * @param object
     * @return
     */
    public static ResponseEntity generateBadResponseEntity(int code, String message, Object object) {
        return ResponseEntity.ok().body(new cn.djun.news.util.BaseResponse<>(code, message, object));
    }

}
